/*******************************************************************************
**
** Copyright (c) 2011 - The OWE Team
**
** This file is part of OWE.
**
** OWE is a free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; version
** version 2.1 of the License.
**
** OWE is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with OWE. If not, see <http://www.gnu.org/licenses/>.
**
*******************************************************************************/

#include <owe/iconelement.h>
#include <owe/node.h>
#include <owe/ustring.h>

OWE_USE_NAMESPACE

/*!
    \class IconElement
    \brief Widget icon

    \ingroup Configuration

    Implementation of the widget icon element as specified
    <a href="http://www.w3.org/TR/widgets/#icon0">here</a>.
*/

/*!
    \fn UString IconElement::src() const

    Returns the widget icon <a href="http://www.w3.org/TR/widgets/#src">
    src</a> (which is actually the icon relative path).
*/

/*!
    \fn UString IconElement::height() const

    Returns the widget icon preferred
    <a href="http://www.w3.org/TR/widgets/#height0">height</a>.
*/

/*!
    \fn UString IconElement::width() const

    Returns the widget icon preferred
    <a href="http://www.w3.org/TR/widgets/#width0">width</a>.
*/

/*!
    Constructs a new IconElement from a given \a node.
*/
IconElement::IconElement(const Node *node)
    : Element(node, Element::Icon)
    , m_src(node->attribute("src"))
    , m_height(node->attribute("height"))
    , m_width(node->attribute("width"))
{
}

/*!
    Destructs the object releasing all allocated resources.
*/
IconElement::~IconElement()
{
}

/*!
    Returns whether a icon is valid. In order to be valid, the icon
    element must contain the src attribute.
*/
bool IconElement::isValid() const
{
    return m_src.size() > 0;
}
